<template>
	<u-navbar 
		:bgColor="bgColor" :title="title" :titleStyle="{color: color}" placeholder
		:leftIconColor="color" :leftIcon="['','home-fill','arrow-left'][icon_type]" @leftClick="leftClick"
	></u-navbar>
</template>

<script>
	export default { 
		props: {
			title: {
				type: String,
				default: '自定义导航栏'
			},
			color: {
				type: String,
				default: '#333333'
			},
			bgColor: {
				type: String,
				default: '#F8F8F8'
			},
			hideBack: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				icon_type: 1,
			}
		},
		created() {
			if(this.hideBack) return this.icon_type = 0;
			let pageList = uni.$u.pages();
			if(pageList.length!=1) this.icon_type = 2
		},
		methods: {
			leftClick() {
				if(this.icon_type==1){
					uni.reLaunch({ url: '/pages/index/index' });
				}else{
					uni.navigateBack();
				}
			}
		},
	}
</script>

<style scoped>
</style>